<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>壹码当先 - 我的作品</title>
    <link href="/pages/css/kefu.css" rel="stylesheet">
    <script type="text/javascript" src="/pages/js/jquery001.js"></script>
    <!-- Chosen CSS -->
    <link href="/pages/css/login-register.css" rel="stylesheet">
    <!-- Pretty Photo CSS -->
    <link href="/pages/css/prettyPhoto.css" rel="stylesheet">

    <!-- Chosen CSS -->
    <link href="/pages/css/dashboard.css" rel="stylesheet">
    <!-- Custom Main StyleSheet CSS -->
    <link href="/pages/style.css" rel="stylesheet">
    <link href="/pages/css/color-2.css" rel="stylesheet">
    <!-- Color CSS -->
    <link href="/pages/css/color.css" rel="stylesheet">
    <!-- Responsive CSS -->
    <link href="/pages/css/responsive.css" rel="stylesheet">


    <script type="text/javascript" src="/pages/js/jquery.min.js"></script>
    <script type="text/javascript">
        $(function () {
            /**
             * 查看用户信息
             */
            $.post("/user/detail", {}, function (result) {
                if (result.status === 1) {
                    var data = result.data;
                    $("#header").html('<img id="header" src="' + data.header + '">');
                    $("#nickName").html(data.nickName);
                    $("#studentId").html(data.studentId);
                } else {
                    alert("用户未登录");
                    window.location.href = "/pages/index.html";
                }
            });
            loadProducts();
        })


        //加载作品列表
        function loadProducts() {
            var url = '/user/product/page';
            $.post(url, {}, function (result) {
                if ((!result.hasOwnProperty('status'))) {
                    if (result.result.length > 0) {
                        var html = '';
                        var products = result.result;
                        for (var i = 0; i < products.length; i++) {
                            html += '<div class="gt_d_courses_wrap default_width mb20">' +
                                    '<figure>' +
                                    '<img src="' + products[i].sbimage + '" alt="">' +
                                    '<figcaption class="gt_listing_rating">' +
                                    '已上传' +
                                    '</figcaption>' +
                                    '</figure>' +
                                    '<div class="gt_d_classes_des">' +
                                    '<h6><a href="javascript:void(0);" onclick="detail('+products[i].id+')">点球大战</a></h6>' +
                                    '<ul>' +
                                    '<li>' +
                                    '<ul class="gt_rating_star">' +
                                    '<li>' +
                                    '<a href="#"><i class="fa fa-star"></i></a>' +
                                    '<a href="#"><i class="fa fa-star"></i></a>' +
                                    '<a href="#"><i class="fa fa-star"></i></a>' +
                                    '<a href="#"><i class="fa fa-star"></i></a>' +
                                    '<a href="#"><i class="fa fa-star"></i></a>' +
                                    '</li>' +
                                    '</ul>' +
                                    '</li>' +
                                    '<li>上传时间：'+products[i].createTime+'</li>' +
                                    '</ul>' +
                                    '<p>简介：'+products[i].introduction+'</p>' +
                                    '<button onclick="deleteProduct('+products[i].id+')">删除</button>' +
                                    '</div>' +
                                    '</div>';
                        }
                        $("#products").html(html);
                    }
                }
            });
        }


        //查看作品详情
        function detail(id){
            localStorage['productId'] = id;
            window.location.href = "/pages/ymdx/users/myworks_detail.html";
        }
        //删除作品
        function deleteProduct(id) {
            if (confirm("是否删除")) {
                var url = "/user/product/delete";
                $.post(url, {id: id}, function (result) {
                    if (result.status === 1) {
                        alert("成功删除");
                        loadProducts();
                    } else {
                        alert("删除失败");
                    }
                })
            }
        }


    </script>
</head>

<body onload="IFrameResize()">

<script type="text/javascript">
    function IFrameResize() {
        //alert(this.document.body.scrollHeight); //弹出当前页面的高度
        var obj = parent.document.getElementById("iframe1");  //取得父页面IFrame对象
        //alert(obj.height); //弹出父页面中IFrame中设置的高度
        obj.height = this.document.body.scrollHeight;  //调整父页面中IFrame的高度为此页面的高度
    }
</script>

<!--Sub Banner Wrap Start -->
<div class="gt_sub_banner_bg default_width">
    <div class="container">
        <div class="gt_sub_banner_hdg  default_width">
            <h2>我的作品</h2>
            <h6>壹码当先&nbsp;·&nbsp;让更多的孩子爱上编程</h6>
        </div>
    </div>
</div>
<!--Sub Banner Wrap End -->
<!--Breadcrumb Wrap End -->
<div class="gt_breadcrumb_bg default_width">
    <div class="container">
        <div class="gt_breadcrumb_wrap default_width">
            <ul>
                <li><a href="/pages/index.html">首页</a></li>
                <li><a href="#">我的作品</a></li>
            </ul>
        </div>
    </div>
</div>
<!--Breadcrumb Wrap End -->

<!--Main Content Wrap Start-->
<div class="gt_content_wrap">
    <!--Classes Wrap Start-->
    <section class="gt_courses_bg">
        <div class="container">

            <!-- Dashboard Side Bar Wrap Start -->
            <div class="col-md-4">
                <div class="gt-user-sidebar">
                    <div class="gt_d_author_wrap">
                        <div class="gt_d_author_pic">
                            <figure id="header">
                                <!--用户头像-->
                            </figure>
                        </div>
                        <div class="gt_d_author_pic_des">
                            <h5 id="nickName"></h5>
                            <span class="gt_hdg_span"></span>
                            <p>学员号</p>
                            <label id="studentId"></label>
                        </div>
                    </div>
                    <div class="gt-usser-account-list">
                        <ul>
                            <li><a href="/pages/ymdx/users/information.html"><i class="icon-book gt-color"></i>个人信息</a>
                            </li>
                            <li><a href="/pages/ymdx/users/myworks.html"><i class="icon-clock-1 gt-color"></i>我的作品</a>
                            </li>
                            <li><a href="/pages/ymdx/users/editpwd.html"><i class="icon-three gt-color"></i>修改密码</a>
                            </li>
                        </ul>
                        <a href="#" class="gt-logout"><i class="icon-arrows-2 gt-color"></i>退出登录</a>
                    </div>
                </div>
            </div>
            <!-- Dashboard Side Bar Wrap End -->

            <!--Classes List Wrap Start-->
            <div class="col-md-8">
                <h4 class="gt_d_title">作品列表</h4>
                <div id="products"class="gt_d_classes_wrap default_width">


                    <div class="gt_d_classes_des">
                        <a href="/pages/ymdx/users/up-myworks.html"
                           style="display: block; width: 100px; height: 50px; background: #0177b5; line-height: 50px;padding-left: 7px; color: #fff;">上传更多作品</a>
                    </div>

                </div>
            </div>
            <!--Classes List Wrap End-->


        </div>
    </section>
    <!--Classes Wrap End-->
</div>
<!--Main Content Wrap End-->

<!--gt Wrapper End-->

<!--Jquery Library-->
<script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>
<!--Bootstrap core JavaScript-->
<script src="http://www.jq22.com/jquery/bootstrap-3.3.4.js"></script>
<!--Custom JavaScript-->
<script src="/pages/js/custom.js"></script>

</body>
</html>
